/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package logica;

import java.io.File;

/**
 *
 * @author andresgodoysalavert
 */
public class FindDrive
{

    private String ruta;

    public void buscarPendrive() throws InterruptedException{
        boolean blas = true;
        String pendriveS = "";
        while(blas == true){
        String sFichero = "/Volumes/";
        File fichero = new File(sFichero);
        File[] listFiles = fichero.listFiles();       
        File pendrive;
        for (int i=0; i<listFiles.length; i++){

           System.out.println("NOMBRE: " +listFiles[i].getName());
           if ((!listFiles[i].getName().equals("BOOTCAMP")) && (!listFiles[i].getName().equals("Macintosh HD"))){
            pendriveS = sFichero + listFiles[i].getName().toString()+"/";
            pendrive = new File(pendriveS);
             if (pendrive.exists())
                 System.out.println("El fichero " + pendriveS + " existe");
                 blas = false;
           }

        }
        Thread.sleep(500);
        }
        this.setRuta(pendriveS);
    }

    /**
     * @return the ruta
     */
    public String getRuta() {
        return ruta;
    }

    /**
     * @param ruta the ruta to set
     */
    public void setRuta(String ruta) {
        this.ruta = ruta;
    }
}
